#ifndef OBSERVER_H
#define OBSERVER_H

#include "coordgeodetic.h"
#include "eci.h"

namespace libsgp4
{

class DateTime;
struct CoordTopocentric;

/**
 * @brief Stores an observers location in Eci coordinates.
 * 存储观察者在ECI坐标系的位置
 */
class Observer
{
public:
    /**
     * Constructor
     * @param[in] latitude observers latitude in degrees
     * @param[in] longitude observers longitude in degrees
     * @param[in] altitude observers altitude in kilometers
     * 经纬度单位是度，海拔高度是km
     */
    Observer(const double latitude,
             const double longitude,
             const double altitude)
        // : m_geo(latitude, longitude, altitude)
        : m_geo(latitude, longitude, altitude, true) // 明确传入弧度
        , m_eci(DateTime(), m_geo)
    {
    }

    /**
     * Constructor
     * @param[in] geo the observers position
     */
    explicit Observer(const CoordGeodetic &geo)
        : m_geo(geo)
        , m_eci(DateTime(), geo)
    {
    }

    /**
     * Set the observers location
     * @param[in] geo the observers position
     */
    void SetLocation(const CoordGeodetic& geo)
    {
        m_geo = geo;
        m_eci.Update(m_eci.GetDateTime(), m_geo);
    }

    /**
     * Get the observers location
     * @returns the observers position
     */
    CoordGeodetic GetLocation() const
    {
        return m_geo;
    }

    /**
     * Get the look angle for the observers position to the object
     * 计算从观察者位置看向某个对象（由Eci类型的参数eci表示）的仰角
     * @param[in] eci the object to find the look angle to
     * @returns the lookup angle
     */
    CoordTopocentric GetLookAngle(const Eci &eci);

private:
    /**
     * @param[in] dt the date to update the observers position for
     * dt是更新的时刻
     */
    void Update(const DateTime &dt)
    {
        if (m_eci != dt)//“Eci.h”中重载的不等于运算符 (operator!=) 用于比较两个DateTime对象
        {
            m_eci.Update(dt, m_geo);
        }
    }

    /** the observers position */
    CoordGeodetic m_geo;
    /** the observers Eci for a particular time */
    Eci m_eci;
};

} // namespace libsgp4

#endif // OBSERVER_H
